<template>
  <div class="wrapper">
    <v-head :menus="topMenu"></v-head>
    <v-menu :items="menus"></v-menu>
    <!-- <v-sidebar></v-sidebar> -->
    <div class="content-box" :class="{'content-collapse':collapse}">
      <v-tags></v-tags>
      <div class="content">
        <keep-alive :include="keepalive">
          <router-view :key="$route.fullPath"/>
        </keep-alive>
      </div>
    </div>
  </div>
</template>

<script>
import vHead from './Header';
import vMenu from './Menu';
import vTags from './Tags.vue';
import bus from './bus';
import loader from '../../utils/Loader';
export default {
  name:'homeTemplate',
  data(){
    return {
      collapse: false,
      topMenu: [],
      menus: [],
      type:'home'
    }
  },
  methods: {
    initMenu () {
      /**
       * 加载菜单
       */
      loader.fillMenus();
      //设置菜单
      this.menus = loader.loadMenusByType(this.type);
      this.topMenu = loader.loadTopMenusByType(this.type);
    }
  },
  components:{
    vHead, vMenu, vTags
  },
  mounted() {
    bus.$on('collapse', msg => {
      this.collapse = msg;
    })
    this.initMenu();
  },
  computed:{
    keepalive(){
      return this.$store.getters.keepAlive;
    }
  }
}
</script>
